/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.ar.entity;

import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.order.entity.serviceorder.ServiceOrder;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotNull;
import java.util.List;
import com.jeesite.common.collect.ListUtils;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 应收单Entity
 * @author YY
 * @version 2021-03-12
 */
@Table(name="t_ar", alias="a", columns={
		@Column(name="ar_id", attrName="arId", label="应收单ID", isPK=true),
		@Column(name="ar_code", attrName="arCode", label="编号"),
		@Column(name="customer_id", attrName="customerId", label="客户"),
		@Column(name="date", attrName="date", label="日期"),
		@Column(name="status1", attrName="status1", label="状态"),
		@Column(name="bill_status", attrName="billStatus", label="单据状态"),
		@Column(name="service_order_id", attrName="serviceOrderId", label="服务订单"),
		@Column(name="payment_account", attrName="paymentAccount", label="收款名字"),
		@Column(name="amount", attrName="amount", label="金额"),
		@Column(name="currency", attrName="currency", label="币种"),
		@Column(name="parent_bill_type", attrName="parentBillType", label="前置单据类型"),
		@Column(name="parent_bill_code", attrName="parentBillCode", label="前置单据编号"),
		@Column(name="create_by", attrName="createBy", label="创建者"),
		@Column(name="create_date", attrName="createDate", label="创建时间"),
		@Column(name="update_by", attrName="updateBy", label="更新者"),
		@Column(name="update_date", attrName="updateDate", label="更新时间"),
		@Column(name="remarks", attrName="remarks", label="备注信息", queryType=QueryType.LIKE),
	},joinTable = {
		@JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = Customer.class, attrName = "customer", alias = "b",
				on = "b.customer_id = a.customer_id", columns = {
				@Column(name = "customer_id", label = "客户编号", isPK = true),
				@Column(name = "customer_name", label = "客户名称"),
		}),
		@JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = ServiceOrder.class, attrName = "serviceOrder", alias = "c",
				on = "c.service_order_id = a.service_order_id", columns = {
				@Column(name = "service_order_id", label = "服务订单id", isPK = true),
				@Column(name = "service_order_code", label = "服务订单编号"),
		})


}, orderBy="a.update_date DESC"
)
public class Tar extends DataEntity<Tar> {
	
	private static final long serialVersionUID = 1L;
	private String arId;		// 应收单ID
	private String arCode;		// 编号
	private String customerId;		// 客户

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	private Customer customer;   //客户对象
	private Date date;		// 日期
	private String status1;		// 状态
	private String billStatus;   //单据状态
	private String serviceOrderId;		// 服务订单
	private ServiceOrder serviceOrder;
	private String paymentAccount;		// 收款名字
	private Double amount;		// 金额

	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}

	private String currency;		// 币种
	private String parentBillType;		// 前置单据类型
	private String parentBillCode;		// 前置单据id
	private String parentBillCode1;		// 前置单据编号
	private List<TarDetail> tarDetailList = ListUtils.newArrayList();		// 子表列表

	public String getParentBillCode1() {
		return parentBillCode1;
	}

	public void setParentBillCode1(String parentBillCode1) {
		this.parentBillCode1 = parentBillCode1;
	}

	public String getBillStatus() {
		return billStatus;
	}

	public void setBillStatus(String billStatus) {
		this.billStatus = billStatus;
	}

	public Tar() {
		this(null);
	}

	public Tar(String id){
		super(id);
	}
	
	public String getArId() {
		return arId;
	}

	public void setArId(String arId) {
		this.arId = arId;
	}
	
	@Length(min=0, max=100, message="编号长度不能超过 100 个字符")
	public String getArCode() {
		return arCode;
	}

	public void setArCode(String arCode) {
		this.arCode = arCode;
	}
	
	@NotBlank(message="客户不能为空")
	@Length(min=0, max=64, message="客户长度不能超过 64 个字符")
	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="日期不能为空")
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
	@Length(min=0, max=1, message="状态长度不能超过 1 个字符")
	public String getStatus1() {
		return status1;
	}

	public void setStatus1(String status1) {
		this.status1 = status1;
	}
	
	@Length(min=0, max=64, message="服务订单长度不能超过 64 个字符")
	public String getServiceOrderId() {
		return serviceOrderId;
	}

	public void setServiceOrderId(String serviceOrderId) {
		this.serviceOrderId = serviceOrderId;
	}
	
	@Length(min=0, max=100, message="收款名字长度不能超过 100 个字符")
	public String getPaymentAccount() {
		return paymentAccount;
	}

	public void setPaymentAccount(String paymentAccount) {
		this.paymentAccount = paymentAccount;
	}
	
	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}
	
	@Length(min=0, max=2, message="币种长度不能超过 2 个字符")
	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}
	
	@Length(min=0, max=2, message="前置单据类型长度不能超过 2 个字符")
	public String getParentBillType() {
		return parentBillType;
	}

	public void setParentBillType(String parentBillType) {
		this.parentBillType = parentBillType;
	}
	
	@Length(min=0, max=100, message="前置单据编号长度不能超过 100 个字符")
	public String getParentBillCode() {
		return parentBillCode;
	}

	public void setParentBillCode(String parentBillCode) {
		this.parentBillCode = parentBillCode;
	}
	
	public Date getDate_gte() {
		return sqlMap.getWhere().getValue("date", QueryType.GTE);
	}

	public void setDate_gte(Date date) {
		sqlMap.getWhere().and("date", QueryType.GTE, date);
	}
	
	public Date getDate_lte() {
		return sqlMap.getWhere().getValue("date", QueryType.LTE);
	}

	public void setDate_lte(Date date) {
		sqlMap.getWhere().and("date", QueryType.LTE, date);
	}
	
	public Date getCreateDate_gte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
	}

	public void setCreateDate_gte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
	}
	
	public Date getCreateDate_lte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
	}

	public void setCreateDate_lte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
	}
	
	public Date getUpdateDate_gte() {
		return sqlMap.getWhere().getValue("update_date", QueryType.GTE);
	}

	public void setUpdateDate_gte(Date updateDate) {
		sqlMap.getWhere().and("update_date", QueryType.GTE, updateDate);
	}
	
	public Date getUpdateDate_lte() {
		return sqlMap.getWhere().getValue("update_date", QueryType.LTE);
	}

	public void setUpdateDate_lte(Date updateDate) {
		sqlMap.getWhere().and("update_date", QueryType.LTE, updateDate);
	}
	
	public List<TarDetail> getTarDetailList() {
		return tarDetailList;
	}

	public void setTarDetailList(List<TarDetail> tarDetailList) {
		this.tarDetailList = tarDetailList;
	}

	@Override
	public String toString() {
		return "Tar{" +
				"arId='" + arId + '\'' +
				", arCode='" + arCode + '\'' +
				", customerId='" + customerId + '\'' +
				", date=" + date +
				", status1='" + status1 + '\'' +
				", serviceOrderId='" + serviceOrderId + '\'' +
				", paymentAccount='" + paymentAccount + '\'' +
				", amount=" + amount +
				", currency='" + currency + '\'' +
				", parentBillType='" + parentBillType + '\'' +
				", parentBillCode='" + parentBillCode + '\'' +
				", tarDetailList=" + tarDetailList +
				'}';
	}
}